package com.crm.system.service.impl.contractReviewManager;

import com.crm.common.model.DhPageInfo;
import com.crm.model.qo.customerManager.CustomerOrderBackMoneyQO;
import com.crm.model.vo.customerManager.CustomerOrderBackMoneyVO;
import com.crm.service.contractReviewManager.RefundReviewDbService;
import com.crm.system.service.contractReviewManager.RefundReviewService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 退款审核
 * @Author renshaorong
 * @Date 2021/8/26
 */
@Service
public class RefundReviewServiceImpl implements RefundReviewService {

    @Autowired
    RefundReviewDbService refundReviewDbService;

    /**
     * 审核管理--退款审核列表
     * @param customerOrderBackMoneyQO   ---列表查询参数
     * @param pageIndex/ pageSize    ---页码、分页大小
     * @return
     */
    @Override
    public DhPageInfo<CustomerOrderBackMoneyVO>  selectRefundReviewList(CustomerOrderBackMoneyQO customerOrderBackMoneyQO, Integer pageIndex, Integer pageSize){
        if (pageIndex != null && pageSize != null) {
            PageHelper.startPage(pageIndex, pageSize);
        }

        Integer dateUnit = 0;

        if (!StringUtils.isBlank(customerOrderBackMoneyQO.getDateType())) {
            if ("today".equals(customerOrderBackMoneyQO.getDateType())) {
                //今天
                dateUnit = 1;
            }
            if ("thisWeek".equals(customerOrderBackMoneyQO.getDateType())) {
                //本周
                dateUnit = 2;
            }
            if ("thisMonth".equals(customerOrderBackMoneyQO.getDateType())) {
                //本月
                dateUnit = 3;
            }
        }

        List<CustomerOrderBackMoneyVO> CustomerOrderBackMoneyVOList = refundReviewDbService.selectRefundReviewList(customerOrderBackMoneyQO,dateUnit);
        PageInfo<CustomerOrderBackMoneyVO> pageInfo = new PageInfo<CustomerOrderBackMoneyVO>(CustomerOrderBackMoneyVOList);
        return new DhPageInfo<CustomerOrderBackMoneyVO>(pageInfo, CustomerOrderBackMoneyVOList);
    }

}
